API Documentation
Public Member Functions | List of all members
nkGraphics::BoundingBox Class Referencefinal

A bounding box. Often used to encompass object's bounds in the world. More...

Public Member Functions

 BoundingBox ()
 
 BoundingBox (const nkMemory::BufferView< const nkMaths::Vector > &points)
 
 BoundingBox (const nkMaths::Vector &center, float cubeHalfSide)
 
 BoundingBox (const nkMaths::Vector &center, const nkMaths::Vector &axisAlignedHalfSides)
 
 ~BoundingBox ()
 
nkMemory::BufferView< const nkMaths::VectorgetPoints () const
 
nkMemory::BufferView< const nkMaths::VectorgetTransformedPoints () const
 
nkMaths::Vector getCenter () const
 
nkMaths::Vector getAxisAlignedSides () const
 
void setPoints (const nkMemory::BufferView< const nkMaths::Vector > &points)
 
void setTransformedPoints (const nkMemory::BufferView< const nkMaths::Vector > &points)
 
void updateTransformation (Node *node)
 
bool checkAgainst (const Frustum &frustum) const
 

Detailed Description

A bounding box. Often used to encompass object's bounds in the world.

Can be used to check against a frustum and do culling.

Constructor & Destructor Documentation

◆ BoundingBox() [1/4]

nkGraphics::BoundingBox::BoundingBox ( )

Default constructor.

◆ BoundingBox() [2/4]

nkGraphics::BoundingBox::BoundingBox ( const nkMemory::BufferView< const nkMaths::Vector > &  points)

Points constructor.

Parameters
pointsThe points forming the bounds, in no particular order.

◆ BoundingBox() [3/4]

nkGraphics::BoundingBox::BoundingBox ( const nkMaths::Vector center,
float  cubeHalfSide 
)

Axis aligned constructor with a constant size on 3 axis.

Parameters
centerThe center of the box to create.
cubeHalfSideThe half extent, uniform along the 3 axis (x, y, z), used to form a cube.

◆ BoundingBox() [4/4]

nkGraphics::BoundingBox::BoundingBox ( const nkMaths::Vector center,
const nkMaths::Vector axisAlignedHalfSides 
)

Axis aligned constructor with separated size on 3 axis.

Parameters
centerThe center of the box to create.
axisAlignedHalfSidesThe half extents, for each axis.

◆ ~BoundingBox()

nkGraphics::BoundingBox::~BoundingBox ( )

Destructor.

Member Function Documentation

◆ getPoints()

nkMemory::BufferView<const nkMaths::Vector> nkGraphics::BoundingBox::getPoints ( ) const
Returns
The 8 points forming the box, originally.

◆ getTransformedPoints()

nkMemory::BufferView<const nkMaths::Vector> nkGraphics::BoundingBox::getTransformedPoints ( ) const
Returns
The 8 points forming the box, once transformed by a node transformation.

◆ getCenter()

nkMaths::Vector nkGraphics::BoundingBox::getCenter ( ) const
Returns
The center of the box.

◆ getAxisAlignedSides()

nkMaths::Vector nkGraphics::BoundingBox::getAxisAlignedSides ( ) const
Returns
The half extent on the 3 axis of the box.

◆ setPoints()

void nkGraphics::BoundingBox::setPoints ( const nkMemory::BufferView< const nkMaths::Vector > &  points)

Sets new points to use for the box.

Parameters
pointsThe points to use.

◆ setTransformedPoints()

void nkGraphics::BoundingBox::setTransformedPoints ( const nkMemory::BufferView< const nkMaths::Vector > &  points)

Sets new transformed points to use for the box.

Parameters
pointsThe points to use.
Remarks
Beware that those points can be updated anytime by linked node transformation, if the bounds are attached to a SubEntity.

◆ updateTransformation()

void nkGraphics::BoundingBox::updateTransformation ( Node node)

Updates the transformed points with a node transformation.

Parameters
nodeThe node from which to retrieve the transformation.

◆ checkAgainst()

bool nkGraphics::BoundingBox::checkAgainst ( const Frustum frustum) const

Checks the box against a frustum to know if it is inside or not.

Parameters
frustumThe frustum to check against.
Returns
If the box is inside the frustum (true) or not (false).

The documentation for this class was generated from the following file: